{extend name="base" /}
{block name="content"}
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>商城</span>
            <span class="icon-angle-right"></span>
            <span>订单管理</span>
            <span class="icon-angle-right"></span>
            <span>订单详情</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <thead>
                        <tr>
                            <th colspan="4">查看订单详情</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td width="15%"><label>订单 ID</label></td>
                            <td width="35%">{$info.id}</td>
                            <td width="15%"><label>订单编号</label></td>
                            <td width="35%">{$info.order_no}</td>
                        </tr>

                        <tr>

                            <td width="15%"><label>下单会员</label></td>
                            <td width="35%">{$info.username}</td>
                            <td width="15%"><label>实付积分</label></td>
                            <td width="35%">{$info.pay_amount}</td>
                        </tr>
                        <tr>
                            <td width="15%"><label>收货人</label></td>
                            <td width="35%">{$info.receiver_name}</td>
                            <td width="15%"><label>订单积分</label></td>
                            <td width="35%">{$info.order_amount}</td>
                            <!--<td width="15%"><label>收货人</label></td>-->
                            <!--<td width="35%">{$info.receiver_name}</td>-->
                        </tr>
                        <tr>
                            <td width="15%"><label>收货人联系方式</label></td>
                            <td width="35%">{$info.receiver_mobile}</td>
                            <td width="15%"><label>收货人地址</label></td>
                            <td width="35%">{$info.receiver_province}{$info.receiver_city}{$info.receiver_district}{$info.receiver_address}</td>
                        </tr>

                            <td width="15%"><label>订单状态</label></td>
                            <td width="35%" data-id="{$info.id}" data-status-id="{$info.order_status_id}" class="">

                                       {$info.order_status_txt}


                            </td>
                            <td width="15%"><label>兑换时间</label></td>
                            <td width="35%">{$info.pay_time_date}</td>
                        </tr>

                        <tr>
                            <td width="15%"><label>发货时间</label></td>
                            <td width="35%">{$info.send_time_date}</td>
                            <td width="15%"><label>签收时间</label></td>
                            <td width="35%">{$info.sign_time_date}</td>
                        </tr>

                        <tr>
                            <td width="15%"><label>订单完成时间</label></td>
                            <td width="35%">{$info.finish_time_date}</td>

                        </tr>


                            <tr hidden>
                                <td width="15%"><label>物流公司</label></td>
                                <td width="35%"><input style="width: 80%;height: 20px" type="text" name="wl_title" value="{$info.wl_title}"></td>
                                <td width="15%"><label>物流单号</label></td>
                                <td><input style="width: 80%;height: 20px" type="text" name="wl_number" value="{$info.wl_number}"></td>
                            </tr>


                        </tbody>
                        <thead>
                        <tr>
                            <th colspan="4">订单商品</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td colspan="4">
                                <table class="m-table m-fields">
                                    <thead>
                                    <tr>
                                        <th width="40%">商品名称</th>
                                        <th width="10%">所需积分</th>

                                        <th width="10%">数量</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {foreach name="$info['goods_list']" item="v"}
                                    <tr>
                                        <td>{$v.goods_name}</td>

                                        <td>{$v.sale_price}</td>

                                        <td>{$v.goods_nums}</td>
                                    </tr>
                                    {/foreach}
                                    </tbody>


                                </table>
                            </td>
                        </tr>
                        </tbody>
                    </table>

                    <div style="width:100%;text-align: center;margin-top: 10px;">
                        {if condition="$info['shipping_method'] neq 2"}
                                <span style="border:0px;background-color:transparent;" data-id="{$info.id}" data-status-id="{$info.order_status_id}" class="m-order-action">
                                    {if condition="$info['order_status_id'] eq 0"}
                                    <!-- 待确认 -->
                                    <a data-order-status="1">确认订单</a>
                                    {elseif condition="$info['order_status_id'] eq 1"}
                                    <!-- 已确认 -->
                                    {elseif condition="$info['order_status_id'] eq 2"}
                                    <!-- 已取消 -->
                                    {elseif condition="$info['order_status_id'] eq 3"}
                                    <!-- 已关闭 -->
                                    {elseif condition="$info['order_status_id'] eq 4"}
                                    <!-- 待付款 -->
                                    <a data-pay-status="1">确认收款</a>
                                    {elseif condition="$info['order_status_id'] eq 5"}
                                    <!-- 待发货 -->
                                    <a data-shipping-status="1">确认发货</a>
                                    {elseif condition="$info['order_status_id'] eq 6"}
                                    <!-- 待收货 -->
                                    <a data-shipping-status="2">确认收货</a>
                                    {elseif condition="$info['order_status_id'] eq 7"}
                                    <!-- 申请退货 -->
                                    <a data-shipping-status="3">同意退货</a>
                                    {elseif condition="$info['order_status_id'] eq 8"}
                                    <!-- 退货中 -->
                                    <a data-shipping-status="4">确认退货</a>
                                    {elseif condition="$info['order_status_id'] eq 9"}
                                    <!-- 已退货 -->
                                    {elseif condition="$info['order_status_id'] eq 10"}
                                    <!-- 申请退款 -->
                                    <a data-pay-status="2">同意退款</a><a data-pay-status="3">取消退款</a>
                                    {elseif condition="$info['order_status_id'] eq 11"}
                                    <!-- 退款中 -->
                                    <a data-pay-status="4">确认退款</a>
                                    {elseif condition="$info['order_status_id'] eq 12"}
                                    <!-- 拒绝退款 -->
                                    {elseif condition="$info['order_status_id'] eq 13"}
                                    <!-- 已退款 -->
                                    {elseif condition="$info['order_status_id'] eq 14"}
                                    <!-- 已收货 -->
                                    {elseif condition="$info['order_status_id'] eq 15"}
                                    <!-- 已完成 -->
                                    {/if}
                            </span>
                        {/if}
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="extrajs"}
<script>
    $(function(){
        $('.m-order-action a').on('click', function(){
            var id              = $(this).parent().attr('data-id');
            var order_status    = $(this).attr('data-order-status');
            var pay_status      = $(this).attr('data-pay-status');
            var shipping_status = $(this).attr('data-shipping-status');
            var status = {
                id: id
            };
            if (typeof(order_status) !== "undefined") {
                status.order_status = order_status;
            }
            if (typeof(pay_status) !== "undefined") {
                status.pay_status = pay_status;
            }
            if (typeof(shipping_status) !== "undefined") {
                status.shipping_status = shipping_status;
            }

            //确认收货
            if(shipping_status=='1' || shipping_status==2){
                status.wl_title =  $("input[name='wl_title']").val();
                status.wl_number = $("input[name='wl_number']").val();
            }

            //询问框
            layer.confirm('您确定要执行此操作吗？', {
                btn: ['确定', '取消']
            }, function(){
                $.post('{:url("orderAction")}', status, function(ret){
                    if (ret.status == 0) {
                        dialog.success(ret.message, function(){
                            window.location.reload();
                        });
                    } else {
                        dialog.error(ret.message);
                    }
                }, 'json');
            }, function(){

            });
        });
    })
</script>
{/block}